<template>
    <div class="head">
        <div class="head-wrapper">
            <div class="avatar">
                <img width="64" height="64" :src="seller.avatar" />
            </div>
            <div class="content-wrapper">
                <div class="title">
                    <span class="brand"></span>
                    <div class="seller-name">{{seller.name}}</div>
                </div>
                <div class="description">{{seller.description}}/{{seller.deliveryTime}}分钟送达</div>
                <div class="support" v-if="seller.supports">
                    <span v-if="seller.supports" :class="this.supportIconClass[seller.supports[0].type]" class="support-icon"></span>
                    <span class="support-text">{{seller.supports[0].description}}</span>
                </div>
            </div>
        </div>
        <div class="message-wrapper" @click="toggleDetialPanel(true)">
            <span class="message-count" v-if="seller.supports" >{{seller.supports.length}}个 </span>
            <i class="ico-keyboard_arrow_right"></i>
        </div>
        <div class="message-board" @click="toggleDetialPanel(true)">
            <span class="notice"></span><span class="message-text">{{seller.bulletin}}</span>
            <i class="ico-keyboard_arrow_right"></i>
        </div>
        <div class="bg-wrapper">
            <img width="100%" height="100%" :src="seller.avatar" />
        </div>
        <div class="detail" v-if="isDetailShow">
            <div class="detail-wrapper clearfix">
                <div class="detail-main">
                    <div class="detail-title">{{seller.name}}</div>
                    <RatingBar :size="48" :score="seller.score"></RatingBar>
                    <div class="youhui">
                        <span class="divider"></span>
                        <span class="youhui-title">优惠信息</span>
                        <span class="divider"></span>
                    </div>
                    <div class="support" v-if="seller.supports" v-for="item in seller.supports">
                        <span v-if="supportIconClass" class="support-icon" :class="supportIconClass[item.type]"  ></span>
                        <span  class="support-text">{{item.description}}</span>
                    </div>
                    <div class="gonggao">
                        <span class="divider"></span>
                        <span class="gonggao-title">商家公告</span>
                        <span class="divider"></span>
                    </div>
                    <div class="bulletin">
                        {{seller.bulletin}}
                    </div>
                </div>
            </div>
            <div class="detail-close" @click="toggleDetialPanel(false)">
                <i class="ico-close"></i>
            </div>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
import RatingBar from '../RatingBar/RatingBar'
export default {
  name: 'Head',
  props: {
    seller: {
      type: Object
    }
  },
  data () {
    return {
      supportIconClass: ['decrease', 'discount', 'guarantee', 'invoice', 'special'],
      isDetailShow: false
    }
  },
  methods: {
    toggleDetialPanel (isShow) {
      this.isDetailShow = isShow
    }
  },
  components: {
    RatingBar: RatingBar
  }
}
</script>

<style  lang="stylus" rel="stylesheet/stylus">
@import "../../common/stylus/mixin.styl";
@import "../../common/stylus/iconfont.styl";
.head
  position :relative
  padding-right:24px
  background :rgba(7,17,27,0.5)
  .head-wrapper
    display :flex
    padding :24px 12px 18px 24px
    font-size :0px
    margin-bottom :18px
    .avatar
      width :64px
      height :64px
      margin-right :16px
      border-radius :4px
    .content-wrapper
      width :200px
      height :64px
      font-size :14px
      text-align :left
      color: #ffffff
      .title
        font-size: 0px
        font-weight :bold
        .brand
          width:30px
          height :18px
          vertical-align :top
          display :inline-block
          margin-top :2px
          margin-right :6px
          background-size:30px 18px
          bg-image('brand')
          background-repeat :no-repeat
        .seller-name
          vertical-align :top
          font-size: 16px
          display :inline-block
      .description
        font-size: 12px
        margin-top :4px
      .support
        height :12px
        display :flex
        align-items :center
        margin-top :8px
        .support-text
          font-size:10px
          line-height :10px
          margin-left :4px
        .support-icon
          width :12px
          height :100%
          background-size :12px 12px
          background-repeat :no-repeat
          &.decrease
            bg-image('decrease_1')
          &.discount
            bg-image('discount_1')
          &.guarantee
            bg-image('guarantee_1')
          &.invoice
            bg-image('invoice_1')
          &.special
            bg-image('special_1')
  .message-board
    position :relative
    background :rgba(7,17,27,0.2)
    margin-right :-24px
    height :28px
    line-height :28px
    color:#fff
    padding :0 22px 0 12px
    overflow :hidden
    white-space:nowrap
    text-overflow :ellipsis
    .notice
      display :inline-block
      bg-image('bulletin')
      width :22px
      height :12px
      margin-top :8px
      vertical-align :top
      background-size :22px 12px
      background-repeat :no-repeat
    .message-text
      font-size:10px
      line-height :28px
      margin :0 4px
    .ico-keyboard_arrow_right
      display :inline-block
      position :absolute
      right :12px
      bottom:8.5px
      float :right
      font-size:10px

  .message-wrapper
    height :24px
    line-height :24px
    position :absolute
    padding:7px 16px
    right :30px
    bottom :35px
    font-size:10px
    color:#ffffff
    background :rgba(0,0,0,0.2)
    border-radius :24px
    .ico-keyboard_arrow_right
      vertical-align :top
      font-size :10px
  .bg-wrapper
    left :0
    top :0
    width :100%
    height :100%
    position :absolute
    z-index :-1
    filter :blur(10px)
  .detail
    position :fixed
    top :0
    left :0
    width :100%
    height :100%
    overflow :auto
    background :rgba(7,17,27,0.8)
    color:rgb(255,255,255)
    z-index :100
    .clearfix
      display :inline-block
      &:after
        display :block
        content: "."
        line-height :0
        height :0
        clear: both
        visibility :hidden
    .detail-wrapper
      min-height :100%
      width :100%
      .detail-main
        margin-top :64px
        padding:0 36px 64px 36px
        .detail-title
          font-size :16px
          line-height :16px
          font-weight :700
          text-align :center
          margin-bottom :16px
        .youhui
          display :flex
          width :100%
          height :14px
          margin-top :28px
          align-items :center
          margin-bottom : 24px
          .divider
            display :inline-block
            background-color :rgba(255,255,255,0.2)
            height :2px
            flex :auto
          .youhui-title
            padding:0 12px 0 12px
            color :#ffffff
            font-size :14px
            font-weight :700
            line-height :14px

        .support
          margin-left :12px
          font-size :0px
          .support-icon
            display :inline-block
            vertical-align :top
            width :16px
            height :16px
            margin-bottom :12px
            background-size :16px 16px
            background-repeat :no-repeat
            margin-right :6px
            &.decrease
                bg-image('decrease_1')
            &.discount
                bg-image('discount_1')
            &.guarantee
                bg-image('guarantee_1')
            &.invoice
                bg-image('invoice_1')
            &.special
                bg-image('special_1')
          .support-text
            display :inline-block
            font-size :12px
            font-weight :200
            color:rgb(255,255,255)
            line-height :16px

        .gonggao
          display :flex
          width :100%
          height :14px
          margin-top :28px
          align-items :center
          margin-bottom : 24px
          .divider
            display :inline-block
            background-color :rgba(255,255,255,0.2)
            height :2px
            flex :auto
          .gonggao-title
            padding:0 12px 0 12px
            color :#ffffff
            font-size :14px
            font-weight :700
            line-height :14px
        .bulletin
          margin-top :24px
          margin-left :0 12px 0 12
          font-size :12px
          font-weight :200
          color :rgb(255,255,255)
          line-height :24px
    .detail-close
      position :relative
      width :32px
      height :32px
      margin : -64px auto 0 auto
      clear :both
      font-size :32px
</style>